package com.neusoft.control;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/AjaxDemoServlet")
public class AjaxDemoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * 接受ajax引擎发送的请求处理
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 接受reqeust中的参数值
		String strName = request.getParameter("un");
		String strPsw = request.getParameter("upsw");
		System.out.println("ajax请求的参数："+strName+";"+strPsw);
		// 响应内容
		String strResp = strName+"，欢迎进入系统，您已经登录成功!";
		// 使用response的writer对象将影响内容写出到客户端（类似于socket通信时的响应）
		PrintWriter pw = response.getWriter();
		pw.write(strResp);
		// 清空
		pw.flush();
		// 关闭资源
		pw.close();
	}

}
